package com.wrial.seckill.dao;
/*
 * @Author  Wrial
 * @Date Created in 16:07 2020/4/5
 * @Description
 */

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wrial.seckill.dataobject.ItemStockDO;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface ItemStockDOMapper extends BaseMapper<ItemStockDO> {

    @Select("select * from item_stock where item_id = #{item_id}")
    public ItemStockDO getItemStockByItemId(Integer item_id);

    @Update("update item_stock set stock = stock - #{amount} where item_id = #{itemId} and stock >= #{amount}")
    int decreaseStock(Integer itemId, Integer amount);


}
